package com.qipay.channelType.impl;


import com.qipay.baas.model.ChannelType;
import com.qipay.baas.model.Peizhi;
import com.qipay.channelType.ChannelTypeService;
import com.qipay.mapper.ChannelTypeMapper;
import com.qipay.mapper.PeizhiMapper;
import com.qipay.notice.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;


@Service
public class ChannelTypeServiceImpl implements ChannelTypeService {

    @Autowired
    ChannelTypeMapper channelTypeMapper;

    @Override
    public List<ChannelType> selectAll() {
        List<ChannelType> channelTypes = channelTypeMapper.selectAll();
        return channelTypes;
    }

    @Override
    public ChannelType findById(long id) {
        List<ChannelType> channelTypes = channelTypeMapper.findById(id);
        if(channelTypes!=null&&channelTypes.size()>0)
        return channelTypes.get(0);
        else return null;
    }



    @Override
    public void save(Long id, BigDecimal cpFeeRecharge, BigDecimal agentFeeRecharge,BigDecimal rateAdvance) {
        channelTypeMapper.update(id,cpFeeRecharge,agentFeeRecharge,rateAdvance);
    }

    @Override
    public void save(Long id,Byte status) {
        channelTypeMapper.updateStatus(id,status);
    }

    @Override
    public int insert(ChannelType channelType) {
        channelTypeMapper.insert(channelType);
        Long channelTypeId = channelType.getId();
        return channelTypeId==null?0:channelTypeId.intValue();
    }

    @Override
    public int delete(long id) {
        return channelTypeMapper.deleteByPrimaryKey(id);
    }

    /*
   根据id修改cpFeeRecharge
    */
    @Override
    public void updateCpFeeRechargeByid(Long id, BigDecimal cpFeeRecharge) {
        channelTypeMapper.updateCpFeeRechargeByid(id,cpFeeRecharge);
    }


    /*
    根据id修改agentFeeRecharge
     */
    @Override
    public void updateAgentFeeRechargeByid(Long id, BigDecimal agentFeeRecharge) {

        channelTypeMapper.updateAgentFeeRechargeByid(id,agentFeeRecharge);
    }


    /*
    根据id修改rateAdvance
     */
    @Override
    public void updateRateAdvanceByid(Long id, BigDecimal rateAdvance) {

        channelTypeMapper.updateRateAdvanceByid(id,rateAdvance);
    }


}
